#ifndef P8X32ADEBUGGER_H
#define P8X32ADEBUGGER_H

#include "p8x32acogpanel.h"
#include "debugger.h"
#include "mytabwidget.h"
#include <QTableWidget>
#include <QLineEdit>

class P8x32aDebugger : public Debugger
{
    Q_OBJECT
public:
    P8x32aDebugger();
    virtual ~P8x32aDebugger();
    P8x32aCogPanel *cogPointer(int num);

    enum { HUBCOLS = 16 };

private:

    QString tabText(int n);
    QString tabTextActive(int n);

    int lastCog;

    MyTabWidget tabs;
    QTableWidget hubram;

    QLabel lockLabel;
    QLineEdit locksFreeLineEdit;
    QLabel memUsedLabel;
    QLineEdit memUsedLineEdit;
    QLabel stackUsedLabel;
    QLineEdit stackUsedLineEdit;
    QLabel memFreeLabel;
    QLineEdit memFreeLineEdit;

    QList<P8x32aCogPanel*> coglist;
    P8x32aCogPanel cog0;
    P8x32aCogPanel cog1;
    P8x32aCogPanel cog2;
    P8x32aCogPanel cog3;
    P8x32aCogPanel cog4;
    P8x32aCogPanel cog5;
    P8x32aCogPanel cog6;
    P8x32aCogPanel cog7;

    QList<QTableWidgetItem*> *hubitem;

    int stackPtr;
    int stackBase;
    int stackMark;
    int varBase;
    int objBase;
    int pubPtr;

    QColor colorStackBase;
    QColor colorStackPtr;
    QColor colorPubPtr;
    QColor colorVarStart;
    QColor colorObjStart;
    QColor colorClockMode;
    QColor colorClockFreq;

public slots:
    void clearBreakpoints(int cog);
    void showBreakpoint(int cog, int line);
    void clearCogMem(int cog);
    void addCogInstructions(int cog, QList<uint> code);
    void setCogPC(int cog, int pc);
    void showCog(int cog, CogInfo *info);
    void showCogTab(int cog);
    void clearHubMem();
    void showHubMem(uchar *memptr, int size);
    void pokeHubMem(int addr, int value, int size);
};

#endif // P8X32ADEBUGGER_H
